<?php
class Hotdeals
{
    /**
     * @var object Zend DB Adapter
     */
    private $_db;
    
    public function __construct()
    {
			$this->_db = Zend_Registry::get('db');
    }
    
    public function getHotdealsById($id)
    {
    	$this->_db->query("SET NAMES 'utf8'");
    	$sql = $this->_db->fetchRow("
    		select * from hotdeals
    		WHERE id = " . $id);
    	
    	return $sql;
    }
    
    public function getHotdeals()
    {
        $sysdate = date("Y-m-d");
        $this->_db->query("SET NAMES 'utf8'");
       
    	$sql = $this->_db->fetchAll("SELECT *
                            FROM `hotdeals`
                            WHERE STATUS = 1
                            AND offer_valid_to > '" . $sysdate . "'
                            ORDER BY RAND() LIMIT 0,3
                             ");
    	/*$sql = $this->_db->fetchAll("SELECT a.id AS main_id, a.title AS main_title, a.title_ru AS main_title_ru, a.parentid AS main_parentid, b.id AS sub_id, b.title AS sub_title, b.title_ru AS sub_title_ru, b.parentid AS sub_parentid
                            FROM `specialtext` a
                            LEFT JOIN `specialtext` b ON b.parentid = a.id
                            WHERE NOT (
                            b.id IS NULL
                            AND a.parentid !=0
                            )
                            AND a.status =1");*/
    	return $sql;
    }
} 
?>